package gameobjects;

import resources.Sound;
import resources.Sprite;
import tools.Bounds;
import abstracts.Level;
import abstracts.Spawn;
import abstracts.Task;

public class EyeballSpawn extends Spawn {
    private final Level LEVEL;
    private final Bounds BOUNDS;

    public EyeballSpawn(Level level, int row, int col) {
        LEVEL = level;
        BOUNDS = new Bounds(row, col, 24, 24);
        loop();
    }

    public void loop() {
        TaskQueue tasks = new TaskQueue();
        tasks.add(new Wait(120));
        tasks.add(new Task() {
            @Override
            public boolean isDone() {
                Sound.EYEBALL_SPAWN.play();
                return true;
            }
        });
        tasks.add(new GrowAnimation(BOUNDS, Sprite.EYEBALL_DOWN, 0.0625));
        tasks.add(new Task() {
            @Override
            public boolean isDone() {
                LEVEL.add(new Eyeball(LEVEL, BOUNDS.getMinRow(), BOUNDS
                        .getMinCol()));
                loop();
                return true;
            }
        });
        LEVEL.add(tasks);
        tasks.run(LEVEL);
    }
}
